import gtk
import webkit

class WebView(webkit.WebView):
    def get_html(self):
        self.execute_script('oldtitle=document.title;document.title=document.documentElement.innerHTML;')
        html = self.get_main_frame().get_title()
        self.execute_script('document.title=oldtitle;')
        return html

if __name__ == "__main__":

    view = WebView()

    sw = gtk.ScrolledWindow()
    sw.add(view)

    win = gtk.Window(gtk.WINDOW_TOPLEVEL)
    win.add(sw)
    win.show_all()


    view.open("http://www.google.com")
    html = view.get_html()

    print(html)

    gtk.main()
